package com.github.excel.controller;

import com.github.excel.entity.vo.response.ResponseData;
import com.github.excel.service.IExcelFileService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;

/**
 * excel文件处理
 * @author sjw
 * @since 2024-01-18
 */
@RestController
@RequestMapping("/excelFile")
public class ExcelFileController {

    @Autowired
    private IExcelFileService excelFileService;

    @PostMapping("/importExcelFile")
    @ApiOperation("excel文件导入")
    public ResponseData<List<Map<String, Object>>> importExcelFile(@RequestParam(value = "file", required = true) MultipartFile file) {
        return ResponseData.ok(excelFileService.importExcelFile(file));
    }

    @PostMapping("/exportExcelFile")
    @ApiOperation("excel文件导出")
    public void exportExcelFile() {
        excelFileService.exportExcelFile();
    }
}
